<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增员工')"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body>
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-role-edit">
        <div class="form-group">
            <label class="col-sm-3 control-label ">ID：</label>
            <div class="col-sm-8">
                <input class="form-control" th:field="*{emps.eid}" type="text" name="eid" id="eid" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">姓名：</label>
            <div class="col-sm-8">
                <input class="form-control"th:field="*{emps.name}" type="text" name="name" id="name" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">编号：</label>
            <div class="col-sm-8">
                <input class="form-control"th:field="*{emps.badge}" type="text" name="badge" id="badge" required>
            </div>
        </div>
    </form>
</div>

<th:block th:include="include :: footer"/>
<script type="text/javascript">
    function submitHandler() {
        if ($.validate.form()) {
            edit();
        }
    }

    function edit() {
        var eid = $("input[name='eid']").val();
        var name = $("input[name='name']").val();
        var badge = $("input[name='badge']").val();
        $.ajax({
            cache: true,
            type: "POST",
            url: ctx + "jpbi/emp/edit",
            data: {
                "eid": eid,
                "name": name,
                "badge": badge
            },
            async: false,
            error: function (request) {
                $.modal.alertError("系统错误");
            },
            success: function (data) {
                $.operate.successCallback(data);
            }
        });
    }
</script>

</body>
</html>
